//
//  Cell+Extension.swift
// Scale
//
//  Created by Qiuxk
// on 2018/1/23.
//  Copyright © 2018年 scale. All rights reserved.
//
//

import UIKit

extension UITableViewCell {
    
    class var identifier: String {
        return String(describing: self)
    }
    
    class var nib: UINib {
        return UINib(nibName: identifier, bundle: nil)
    }
    
    open override func addSubview(_ view: UIView) {
        if #available(iOS 14.0, *) {
            // 避免将 contentView 添加到自身或重复添加
            if view != contentView {
                contentView.addSubview(view)
            } else {
                super.addSubview(view)
            }
        } else {
            super.addSubview(view)
        }
    }
}

extension UITableViewHeaderFooterView {
    
    class var identifier: String {
        return String(describing: self)
    }
    
    class var nib: UINib {
        return UINib(nibName: identifier, bundle: nil)
    }
    
}

extension UICollectionReusableView {
    
    class var identifier: String {
        return String(describing: self)
    }
    
    class var nib: UINib {
        return UINib(nibName: identifier, bundle: nil)
    }
    
}
extension UIViewController {
    class var toString: String {
        return String(describing: self)
    }
}

